#!/usr/bin/env bash
set -euo pipefail

crowd_conf=opt/sonatype/nexus/etc/crowd.properties

rm -f $crowd_conf

if [ "$CROWD_ENABLED" = 'true' ]; then
    echo crowd enabled with $CROWD_URL
    touch $crowd_conf
    echo "crowd.server.url=$CROWD_URL" >>  $crowd_conf
    echo "application.name=$CROWD_NAME" >> $crowd_conf
    echo "application.password=$CROWD_PASSWORD" >> $crowd_conf
    echo "cache.authentication=$CROWD_CACHE" >> $crowd_conf
else
    echo crowd disabled
fi


exec "$@"

